package com.loading;

import java.util.List;

public class HashStrategy extends Strategy{

    @Override
    public int choose(int size,Object o) throws Exception{
        //取后8位sequence，和后8位timestamp
        long id = (long)o;
        int mask = Integer.MAX_VALUE>>23;
        int hash = (int) ((id>>23&mask)<<8|id&mask);
        hash = hash^hash>>>8;
        int choose = hash&size-1;
        return choose;
    }
}
